<?php
include("../includes/common.php");
if($islogin2==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");
include './head.php';
$yoursendtime=date('Y-m-d H:i:s',$userrow['level_endtime']);
$money_rate=100-$conf['money_rate'];
$money_rate_vip=100-$conf['money_rate_vip'];
$money_rate_svip=100-$conf['money_rate_svip'];
?>
<script src="../assets/layer/layer.js"></script>
<?php
if(isset($_GET['act'])){
            $notify_url   = $siteurl . 'notify_getvip.php';
            $return_url   = $siteurl . 'huan.php?act=getvipok';
            $trade_no     = date("YmdHis") . rand(11111, 99999);
            $out_trade_no = date("YmdHis") . rand(111, 999);
            $domain       = getdomain($notify_url);
         $level=$userrow['level'];
  if($_GET['act']=='getvip'){
//升级会员
  if($level==1){
    //升级到黄金会员
    if($conf['level_vip']>0)
    {
      if($userrow['money']<$conf['level_vip'])
      {
        //余额不足，跳转在线支付
            if (!$DB->query("insert into `pay_order` (`trade_no`,`out_trade_no`,`notify_url`,`return_url`,`type`,`pid`,`addtime`,`name`,`money`,`domain`,`ip`,`status`) values ('" . $trade_no . "','" . $out_trade_no . "','" . $notify_url . "','" . $return_url . "','no','" . $conf['reg_pid'] . "','" . $date . "','{$pid}升级黄金会员','" . $conf['level_vip'] . "','" . $domain . "','" . $clientip . "','0')")) {
                exit("<script language='javascript'>alert('余额不足，在线支付订单创建失败！');history.go(-1);</script>");
            }
      exit("<script language='javascript'>
      
            layer.open({
            type: 1,
            title: '支付确认页面',
            skin: 'layui-layer-rim',
            content: '<li class=\"layui-form-item\"><b>所需支付金额：</b>{$conf['level_vip']}元</li><li class=\"list-group-item text-center\"><a href=\"../submit2.php?type=alipay&trade_no={$trade_no}\" class=\"btn btn-default\"><img src=\"../assets/icon/alipay.ico\" class=\"logo\">支付宝</a>&nbsp;<a href=\"../submit2.php?type=wxpay&trade_no={$trade_no}\" class=\"btn btn-default\"><img src=\"../assets/icon/wechat.ico\" class=\"logo\">微信支付</a>&nbsp;<a href=\"../submit2.php?type=qqpay&trade_no={$trade_no}\" class=\"btn btn-default\"><img src=\"../assets/icon/qqpay.ico\" class=\"logo\">QQ钱包</a>&nbsp;<li class=\"list-group-item\">提示：支付完成后请到主页查看到账信息</li>'});
            </script>
            ");
      }else
      if($DB->exec("update `pay_user` set `money`=`money`-{$conf['level_vip']},`level`=2,`level_endtime`='{$addtime}' where `name`={$pid}"))
        {
          //扣款成功
            if (!$DB->query("insert into `pay_order` (`trade_no`,`out_trade_no`,`notify_url`,`return_url`,`type`,`pid`,`addtime`,`name`,`money`,`domain`,`ip`,`status`,`buyer`) values ('" . $trade_no . "','" . $out_trade_no . "','" . $notify_url . "','" . $return_url . "','余额支付','" . $conf['reg_pid'] . "','" . $date . "','{$pid}升级黄金会员','" . $conf['level_vip'] . "','" . $domain . "','" . $clientip . "','1','{$pid}')")) {
        $DB->exec("update `pay_user` set `money`={$userrow['money']},`level`=1 where `name`={$pid}");
              exit("<script language='javascript'>alert('充值失败！请重试！');history.go(-1);</script>");
            }
            exit("<script language='javascript'>alert('升级成功！您已成功升级到黄金会员！');history.go(-1);</script>");
        }else{
          exit("<script language='javascript'>alert('无法升级！扣款失败！');history.go(-1);</script>");
        }
          
    }else{
      exit("<script language='javascript'>alert('无法升级！原因有：站长未初始化价格');history.go(-1);</script>");
    }
  }elseif($level==2){
        if($conf['level_svip']>0)
    {
       if($userrow['money']<$conf['level_svip'])
      {
        //余额不足，跳转在线支付
            if (!$DB->query("insert into `pay_order` (`trade_no`,`out_trade_no`,`notify_url`,`return_url`,`type`,`pid`,`addtime`,`name`,`money`,`domain`,`ip`,`status`) values ('" . $trade_no . "','" . $out_trade_no . "','" . $notify_url . "','" . $return_url . "','no','" . $conf['reg_pid'] . "','" . $date . "','{$pid}升级钻石会员','" . $conf['level_svip'] . "','" . $domain . "','" . $clientip . "','0')")) {
                exit("<script language='javascript'>alert('余额不足，在线支付订单创建失败！');history.go(-1);</script>");
            }
      exit("<script language='javascript'>
      
            layer.open({
            type: 1,
            title: '支付确认页面',
            skin: 'layui-layer-rim',
            content: '<li class=\"list-group-item\"><b>所需支付金额：</b>{$conf['level_svip']}元</li><li class=\"list-group-item text-center\"><a href=\"../submit2.php?type=alipay&trade_no={$trade_no}\" class=\"btn btn-default\"><img src=\"../assets/icon/alipay.ico\" class=\"logo\">支付宝</a>&nbsp;<a href=\"../submit2.php?type=wxpay&trade_no={$trade_no}\" class=\"btn btn-default\"><img src=\"../assets/icon/wechat.ico\" class=\"logo\">微信支付</a>&nbsp;<a href=\"../submit2.php?type=qqpay&trade_no={$trade_no}\" class=\"btn btn-default\"><img src=\"../assets/icon/qqpay.ico\" class=\"logo\">QQ钱包</a>&nbsp;<li class=\"list-group-item\">提示：支付完成后请到主页查看到账信息</li>'});

            </script>
            ");
      }else
      if($DB->exec("update `pay_user` set `money`=`money`-{$conf['level_svip']},`level`=3,`level_endtime`='{$addtime}' where `name`={$pid}"))
        {
          //扣款成功
             if (!$DB->query("insert into `pay_order` (`trade_no`,`out_trade_no`,`notify_url`,`return_url`,`type`,`pid`,`addtime`,`name`,`money`,`domain`,`ip`,`status`,`buyer`) values ('" . $trade_no . "','" . $out_trade_no . "','" . $notify_url . "','" . $return_url . "','余额支付','" . $conf['reg_pid'] . "','" . $date . "','{$pid}升级钻石会员','" . $conf['level_vip'] . "','" . $domain . "','" . $clientip . "','1','{$pid}')")) {
        $DB->exec("update `pay_user` set `money`={$userrow['money']},`level`=2,`level_endtime`='0' where `name`={$pid}");
              exit("<script language='javascript'>alert('充值失败！请重试！');history.go(-1);</script>");
            }
            exit("<script language='javascript'>alert('升级成功！您已成功升级到钻石会员！');history.go(-1);</script>");
        }else{
          exit("<script language='javascript'>alert('无法升级！扣款失败！');history.go(-1);</script>");
        }
          
    }else{
      exit("<script language='javascript'>alert('无法升级！站长未初始化价格');history.go(-1);</script>");
    }
  }else{
    exit("<script language='javascript'>alert('无法升级！级别已满');history.go(-1);</script>");
  }
}
}
?>
<div class="clearfix"></div>  
  <div class="content-wrapper">
    <div class="container-fluid">
     <div class="row pt-2 pb-2">
        <div class="col-sm-9">
            <h4 class="page-title">商户资料</h4>
            <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="javaScript:void();">商户</a></li>
            <li class="breadcrumb-item"><a href="javaScript:void();">资料</a></li>
            <li class="breadcrumb-item active" aria-current="page">信息</li>
         </ol>
       </div>
     </div>
      <div class="row">
        <div class="col-lg-4">
           <div class="card profile-card-2">
            <div class="card-img-block">
                <img class="img-fluid" src="/user/kuyun/images/gallery/31.jpg" alt="Card image cap">
            </div>
            <div class="card-body pt-5">
             <img class="profile" src="<?php echo ($userrow['qq'])?'//q2.qlogo.cn/headimg_dl?bs=qq&dst_uin='.$userrow['qq'].'&src_uin='.$userrow['qq'].'&fid='.$userrow['qq'].'&spec=100&url_enc=0&referer=bu_interface&term_type=PC':'assets/img/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg'?>" alt="profile-image">
                <?php if($userrow['level']==2){?>
                <h5 class="card-title">黄金会员</h5>
                会员到期时间：<?php echo $yoursendtime ?>
                <a href="?act=getvip"><span class="badge badge-pill badge-danger m-1">升级</span></a>
                <?php } elseif($userrow['level']==3){?>
                <h5 class="card-title">钻石会员</h5>
                 会员到期时间：<?php echo $yoursendtime ?>
                <?php } else{?>
                 <h5 class="card-title">普通会员</h5>
                 会员到期时间：<?php echo $yoursendtime ?>
                <a href="?act=getvip"><span class="badge badge-pill badge-danger m-1">升级</span></a>
                <?php }?>
                 
                <div class="icon-block">
                </div>

            </div>
        </div>
          <div class="card">
            <div class="card-body">
              <h5 class="card-title">通道费率</h5>
              <div class="table-responsive">
               <table class="table">
                  <thead>
                    <tr>
                      <th scope="col">接口名称</th>
                      <th scope="col">接口类型</th>
                      <th scope="col">通道费率</th>
                      <th scope="col">接口状态</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <th scope="row">支付宝</th>
                      <td>alipay</td>
                      <td><span class="badge badge-pill badge-secondary m-1"><?php echo $money_rate;?>%</span></td>
                      <?php if ($conf['alipay_api']==4){
                        echo '<td><span class="badge badge-pill badge-danger m-1">维护</span></td>';
                      }else{
                        echo '<td><span class="badge badge-success m-1">正常 </span></td>';
                      }
                      ?>
                    </tr>
                    <tr>
                      <th scope="row">微信</th>
                      <td>wxpay</td>
                      <td><span class="badge badge-pill badge-secondary m-1"><?php echo $money_rate;?>%</span></td>
                     <?php if ($conf['wxpay_api']==4){
                        echo '<td><span class="badge badge-pill badge-danger m-1">维护</span></td>';
                      }else{
                        echo '<td><span class="badge badge-success m-1">正常 </span></td>';
                      }
                      ?>
                    </tr>
                    <tr>
                      <th scope="row">QQ</th>
                      <td>QQpay</td>
                      <td><span class="badge badge-pill badge-secondary m-1"><?php echo $money_rate;?>%</span></td>
                      <?php if ($conf['qqpay_api']==4){
                        echo '<td><span class="badge badge-pill badge-danger m-1">维护</span></td>';
                      }else{
                        echo '<td><span class="badge badge-success m-1">正常 </span></td>';
                      }
                      ?>
                    </tr>
                  </tbody>
                </table>
            </div>
            </div>
          </div>
        </div>

        <div class="col-lg-7">
           <div class="card">
            <div class="card-body">
                <div class="tab-pane" id="edit">
                    <form  method="post">
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">会员账号</label>
                            <div class="col-lg-7">
                                <input class="form-control" type="text" value="<?php echo $pid;?>" disabled>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">商户ID</label>
                            <div class="col-lg-7">
                                <input class="form-control" type="text"  value="<?php echo $userrow['id']?>" disabled>
                            </div> 
                        </div>
                       <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">商户秘钥</label>
                            <div class="col-lg-7">
                                <input class="form-control" type="text"  value="<?php echo $userrow['key']?>" disabled> 
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">Q Q</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" name="qq" value="<?php echo $userrow['qq']?>" required="required">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">网站域名</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" name="url" value="<?php echo $userrow['url']?>" placeholder="请输入您的域名链接" required="required">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">QQ邮箱</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="email" name="email" value="<?php echo $userrow['email']?>" disabled placeholder="为了您的账户安全请绑定您的新邮箱！" disabled>

                           </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">安全码设置</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" name="safecode" value="<?php echo $userrow['safecode']?>" placeholder="为了您的账户安全请设置安全码！" >

                           </div>
                        </div>
                      
                     <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label">登入密码修改</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" name="pwd" value="" placeholder="默认为空则不修改！" >

                           </div>
                        </div> 
					   
                       
                        <div class="form-group row">
                            <label class="col-lg-3 col-form-label form-control-label"></label>
                            <div class="col-lg-9">
                                <button type="button" id="editInfo" value="确定修改" class="btn btn-secondary btn-square waves-effect waves-light m-1">确定修改</button>
                                <input type="button" isbind="<?php if($userrow['email'])echo 1;else{echo 2;} ?>"  id="checkbind" value="<?php if($userrow['email'])echo "解绑邮箱";else echo "绑定新邮箱";  ?>" class="btn btn btn-danger  waves-effect waves-light m-1">
                         </div>
                        </div>
                     </form>
                </div>
            </div>
        </div>
      </div>
      </div> 
    </div>
    </div>
   </div>
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
<script src="/user/kuyun/lib/layui/layui.js" charset="utf-8"></script>
<script>
        $("#editInfo").click(function(){
            var email=$("input[name='email']").val();
            var qq=$("input[name='qq']").val();
            var url=$("input[name='url']").val();
            var safecode=$("input[name='safecode']").val();
            var pwd=$("input[name='pwd']").val();
            if(email=='' || qq=='' || url=='' || safecode==''){layer.alert('请确保各项不能为空！');return false;};
           if (url.indexOf(" ")>=0){
                url = url.replace(/ /g,"");
            }
            if (url.toLowerCase().indexOf("http://")==0){
                url = url.slice(7);
            }
            if (url.toLowerCase().indexOf("https://")==0){
                url = url.slice(8);
            }
            if (url.slice(url.length-1)=="/"){
                url = url.slice(0,url.length-1);
            }
           // $("input[name='url']").val(url);
            var ii = layer.load(2, {shade:[0.1,'#fff']});
            $.ajax({
                type : "POST",
                url : "ajax2.php?act=edit_info",
                data : {email:email,qq:qq,url:url,safecode:safecode,pwd:pwd},
                dataType : 'json',
                success : function(data) {
                    layer.close(ii);
                    if(data.code == 1){
                      
                     layer.alert('修改信息成功！');
                    }else{
                     
                       layer.alert(data.msg);
                    }
               }
            });
        });
        $("#checkbind").click(function(){
            if($(this).attr('isbind')==1)
                situationshow("mibao");
            else
                situationshow("bind");
            $.ajax({
                type : "GET",
                url : "ajax2.php?act=checkbind",
                dataType : 'json',
                success : function(data) {
                    if(data.code == 1){
                        
                    }else if(data.code == 2){
                        
                    }else{
                        layer.alert(data.msg);
                    }
                }
            });
        });

        function situationshow(situation){
            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['450px', '250px'], //宽高
                btn:['确认','关闭'],
                title:'验证密保信息',
                content: "<div class=\"form-group row\">\n" +
                    "    <label class=\"col-lg-3 col-form-label form-control-label\">密保邮箱：</label>\n" +
                    "    <div class=\"col-lg-8\">\n" +
                    "        <input id='email-use' type=\"email\" style='background:white;' name=\"title\" lay-verify=\"title\" <?php if($userrow['email'])echo 'readonly';  ?> autocomplete=\"off\" value=\"<?php echo $userrow['email'];?>\" placeholder=\"请输入邮箱\" class=\"form-control\">\n" +
                    "    </div>\n" +
                    "</div>\n" +
                    "<div class=\"layui-form-item\" style='white-space:nowrap;'>\n" +
                    "\n" +

                    "        <input id='veify-win' type=\"text\" name=\"title\" lay-verify=\"title\" autocomplete=\"off\" placeholder=\"请输入验证码\"  style=\"float:left;width:72%;background:white;\" class=\"form-control\">\n" +

                    "    <button class=\"btn btn btn-danger  waves-effect waves-light m-1\" id=\"sendver_win\"  style='float:right'>获取验证码</button>\n" +
                    "</div>",

                yes:function(){
                    var veify=$('#veify-win').val();
                    if(''==veify){
                        layer.alert('请输入验证码！');
                        return false;
                    }
                    $.post('/user/ajax2.php?act=verifycode',{code:veify},function(data){
                        if(data.code=='-1'){
                            layer.alert(data.msg);

                        }else{

                            $.post('/user/ajax2.php?act=setemail',{email:$('#email-use').val()},function(datas){
                                if(datas.code=='1'){
                                    layer.msg('操作成功');
                                    setTimeout(function(){
                                        location.reload();
                                    },800);
                                }else{
                                    layer.alert(datas.msg);
                                }
                            });

                        }



                    });

                } ,success(){
                    $('#sendver_win').click(function(){
                        sendver_win(situation);
                    });

                }

            });
        }
        /*获取验证码*/
        function sendver_win(situation){

            var ema=$('#email-use').val();
            if(ema==""){
                layer.alert("请输入邮箱");
                return false;
            }

            var myReg=/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/;

            if(myReg.test(ema)){

            }else{
                layer.alert("邮箱格式不对!");
                return false;
            }


            $.ajax({
                type : "POST",
                url : "ajax2.php?act=sendcode",
                data : {
                    situation:situation,
                    email:ema
                },
                dataType : 'json',
                success : function(data) {

                    if(data.code == 0){
                        layer.msg('发送成功，请注意查收！');

                        set_sendemail_time($('#sendver_win'));
                    }else{
                        layer.alert(data.msg);

                    }
                }
            });

        }
        function set_sendemail_time(th){
            th.attr('disabled',true);
            var time=60;
            th.prev().css("width",'60%');
            th.html(time+' 秒后可再次发送');
            var seti1=setInterval(function(){
                if(time--!=0){
                    th.html(time+' 秒后可再次发送');
                }else{
                    th.attr('disabled',false);
                    clearInterval(seti1);
                    th.prev().css("width",'72%');
                    th.html('获取验证码');
                }
            },1000);
        }
    </script>
    <?php include 'foot.php';?>
